Skip to content

Integrate the STORE API for automated user insertion into groups#101

Merged
kigiri merged 4 commits intomasterfrom
100-integrate-the-store-api-for-automated-user-insertion-into-groups
Mar 18, 2026
Merged

Integrate the STORE API for automated user insertion into groups#101
kigiri merged 4 commits intomasterfrom
100-integrate-the-store-api-for-automated-user-insertion-into-groups

Conversation

@abdotop
Copy link
Member

@abdotop abdotop commented Mar 13, 2026

refactor: externalize team management to use lmdb-store for Google Groups.

@abdotop abdotop linked an issue Mar 13, 2026 that may be closed by this pull request
@abdotop abdotop self-assigned this Mar 13, 2026
const allData = await get<GoogleGroupItem[]>('google/group', {
q: `select((.kind == "admin#directory#group" and .id == "${id}") or (.kind == "admin#directory#member" and (._key | split("/")[2]) == "${id}"))`,
})

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get group first: google/group/${id}, .name
get members: google/group/${id}/member { email: .email, .id: .id, name: get("google/user", .id) | .fullName }

@abdotop abdotop marked this pull request as ready for review March 17, 2026 13:56
@abdotop abdotop force-pushed the 100-integrate-the-store-api-for-automated-user-insertion-into-groups branch from 993422f to 1767154 Compare March 18, 2026 10:43
api/auth.ts Outdated
userPicture,
})
if (userInfo.picture) {
userInfo.picture = await savePicture(userInfo.picture)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userInfo.picture &&= await savePicture(userInfo.picture)

pending.add(p)
p.finally(() => pending.delete(p))
return 1
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove set and batch logic

@abdotop abdotop force-pushed the 100-integrate-the-store-api-for-automated-user-insertion-into-groups branch from 1767154 to 28ea887 Compare March 18, 2026 10:58
const userInTeam = async (teamId: string, userId?: string) => {
if (!userId) return false
const matches = await get<{ id: string }[]>(
`google/group/${teamId}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the key is `google/group/${teamId}/members/${id}` so this should be sufficient to check if he is present in the group, using getOne

api/routes.ts Outdated
const groups = await get<{ id: string; name: string }[]>(
'google/group',
{
q: 'select((.kind == "admin#directory#group") and (.email | contains("@01edu")) and (.directMembersCount > 1)) | { id: .id, name: .name }',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use endswith('@01edu.ai') over contains it's faster

if (!group) throw respond.NotFound({ message: 'Team not found' })

const members = await get<{ id: string; email: string }[]>(
`google/group/${id}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure we don't have the group itself as a result

const team = TeamsCollection.get(teamId)
if (!team) throw respond.NotFound({ message: 'Team not found' })
return team
fn: async (_ctx, { id }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const userNamesCache = new Map<string, string>()
export const getUserName = async (id: string) => {
  const cachedName = userNamesCache.get(id)
  if (cachedName) return cachedName
  const user = await getOne<{ name: { fullName: string } }>(
    'google/user',
    id,
  )
  userNamesCache.set(id, user.fullName)
  return user.fullName
}

api/routes.ts Outdated
User,
UserDef,
UsersCollection,
// UsersCollection,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔪

api/user.ts Outdated
import { UsersCollection } from '/api/schema.ts'
import { getOne } from './lmdb-store.ts'
import { GoogleUserInfo } from './auth.ts'
// import { UsersCollection } from '/api/schema.ts'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔪

} catch (error) {
console.error('Error creating ClickHouse table:', { error })
Deno.exit(1)
// Deno.exit(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔪

// if ((e.target as HTMLInputElement).checked) {
// addUserToTeam(user, team)
// } else removeUserFromTeam(user, team)
// }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔪


<PageContent>
{!hasTeams
{sortedTeams.length === 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sortedTeams.length < 1

@abdotop abdotop force-pushed the 100-integrate-the-store-api-for-automated-user-insertion-into-groups branch 2 times, most recently from 8a59743 to fab1b8b Compare March 18, 2026 11:22
@abdotop abdotop force-pushed the 100-integrate-the-store-api-for-automated-user-insertion-into-groups branch from fab1b8b to 7559c15 Compare March 18, 2026 11:23
@kigiri kigiri merged commit 26dee08 into master Mar 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate the STORE API for automated user insertion into groups

2 participants